<?php

/**
 * EmsFeature form.
 *
 * @package    ems1
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class EmsFeatureForm extends BaseEmsFeatureForm
{
    public function configure()
    {
        unset ($this['created_at'], $this['updated_at'], $this['features_block_id'],
                $this['is_enabled']
            );

        $context = sfContext::getInstance();

        $this->widgetSchema['content_id']->setOption(
                    'renderer_class',
                    'sfWidgetFormDoctrineJQueryAutocompleter'
                );
        $this->widgetSchema['content_id']->setOption('renderer_options',
                array(
                    'model' => 'EmsContent',
                    'url'   => $context->getController()->genUrl('element_getfeatures'),
                    'config' => '{ limit: 20, extraParams: { portal_id:'.$this->getOption('portal_id').',
                                type_id: function() { return $("select#ems_element_FeaturesBlock_Features_'.
                                $this->getOption('feature_num').'_type_id").val();}}}'
                ));

        if ($this->object->exists())
        {
            $this->widgetSchema['is_enabled'] = new sfWidgetFormInputCheckbox(array('label' => 'Habilitar'));
            $this->validatorSchema['is_enabled'] = new sfValidatorBoolean();
        }

        $this->widgetSchema->setLabels(array(
                'type_id'     => 'Tipo de contenido',
                'content_id'  => 'Contenido',
                'is_new'      => 'Es nuevo'
            ));
    }
}